The present invention relates to an automatic baud rate detector for use with a synchronous or asynchronous serial communications controller.
A serial communications controller controls the transmission and receipt of serial data streams to and from a remote device over a serial communications line. There are two types of serial communications controllers, synchronous and asynchronous. An asynchronous controller is known as a Universal Asynchronous Receiver/Transmitter (UART). An automatic baud rate detector allows a receiving device to accept data from a variety of transmitting devices operating at different speeds without establishing data rates in advance. The baud rate detector determines the speed and logic level of the incoming data stream by examining the first character, which is usually a predefined sign-on character.
For example, the sign-on character may include the eight-bit character 0x0D, which is transmitted with a leading start bit and a trailing, optional parity bit and one or two stop bits. The label "0x" indicates that "0D" is a hexadecimal value. The sequence of bit transmission begins with the start bit, which is followed by the sign-on character from the least significant bit (lsb) to the most significant bit (msb), the optional parity bit and then the one or two stop bits. Since most communications lines are tied to a logic high level when data is not being transmitted over the line, the start bit is typically a logic "0".
Automatic baud rate detection is typically performed by a software routine executed by a host processor that is associated with the receiving device. If the software routine has not previously detected the baud rate, the software routine waits for the user to press Enter (e.g. Carriage Return) and then transmits it as the sign-on character onto the serial output line through the serial communications controller. The software routine waits for the echoed sign-on character to return on the serial input line and then counts how long it takes for the bits of the sign-on character, including the start bit and the stop bits, to arrive on the serial input line. The software routine then calculates the baud rate that is required for transmitting the data to the remote device, stores the baud rate and initializes various transmit function registers in the serial communications controller to transmit at the required baud rate.
In one example, the software routine counts how long it takes for the sign-on character to arrive by reading the input data stream and waiting for it to transition to a logic low level, which is assumed to be the start bit. A timer is started when the serial data stream transitions to a logic high level again with the lsb of the sign-on character. The software routine waits for the remaining bit transitions in the sign-on character and stops the timer at the beginning of the first stop bit. The timer value indicates how many clock cycles passed while the software routine waited for the eight data bits plus the optional parity bit.
A disadvantage of this method of automatic baud rate detection is that the software routine requires a large overhead and thus consumes valuable processing time while the host processor monitors the activity on the serial input line. The host processor is typically dedicated to this function, and must continually wait for the stop bit to arrive and then take immediate action to stop the timer and calculate the baud rate.
Another disadvantage of this method of baud rate detection is that it introduces error into the baud rate calculation, which limits the maximum baud rate it can accurately detect. Most communication systems can tolerate a baud rate error of about three percent without incurring communication problems. With the method discussed above, the host processor must execute three or more instructions once the stop bit has arrived in order to turn off the timer. This introduces an error of several clock cycles into the timer value. The optional parity bit at the end of the sign-on character is an additional source of errors. Since the host processor does not know whether the remote device is transferring a parity bit, the baud rate calculations may be inaccurate if the software routine does not divide the timer value by the correct number of bits. These sources of errors limit the baud rate detection to only about 19,200 baud without incurring a baud rate error above three percent.